home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / Programs / Ipswitch.IMail.Server.Pro.8.0.Winall / IMail8ec.exe / data1.cab / Web_Calendar / jsadevt.js < prev    next >
Encoding:
JavaScript  |  2003-05-07  |  14.4 KB  |  464 lines

  1. //    External Java Script File
  2. //    Do not edit.
  3.  
  4. //----------------Variables for the browser sniffering--------------------
  5.   var agt=navigator.userAgent.toLowerCase();
  6.   var is_major = parseInt(navigator.appVersion); 
  7.   var is_minor = parseFloat(navigator.appVersion); 
  8.   var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
  9.                   && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
  10.                   && (agt.indexOf('webtv')==-1)); 
  11.     var is_ie   = (agt.indexOf("msie") != -1);
  12.     
  13.   var is_nav6up = (is_nav && (is_major >= 5));
  14.   var is_ie5up  = (is_ie  && (is_major >= 4));
  15.  
  16.  
  17.  
  18. //--------------- Function to check if the field is empty -----------------------------------------
  19.             function isEmpty(theField)
  20.             {
  21.                 if(theField == null || theField == "")
  22.                 {
  23.                     return true;
  24.                 }
  25.                 return false;
  26.             }
  27.  
  28. //--------------- Function to check the length of the Event Title ---------------------------------
  29.             function validateTitle(str)
  30.             {
  31.                 len = str.length;
  32.                 if(len > 80 ) 
  33.                 {
  34.                     alert("Please enter title less than 80 characters!");
  35.                     return true;
  36.                 }
  37.                 return false;
  38.             }
  39.  
  40. //--------------- Function to validate the length of the Event Description  -----------------------
  41.             function validateDescription(str)
  42.             {
  43.                 len = str.length;
  44.                 if(len > 255)
  45.                 {
  46.                     alert("Please enter description less than 255 characters!");
  47.                     return true;
  48.                 }
  49.                 else
  50.                 {
  51.                     return false;
  52.                 }
  53.             }
  54.  
  55. //--------------- Function to validate the length of the Event Location  --------------------------
  56.             function validateLocation(str)
  57.             {
  58.                 len = str.length;
  59.                 if(len > 255)
  60.                 {
  61.                     alert("Please enter location less than 255 characters!");
  62.                     return true;
  63.                 }
  64.                 else
  65.                 {
  66.                     return false;
  67.                 }
  68.             }
  69.  
  70. //--------------- Function to validate the length of the URL -----------------------
  71.             function validateURL(str)
  72.             {
  73.                 len = str.length;
  74.                 if(len > 255)
  75.                 {
  76.                     alert("Please enter URL less than 255 characters!");
  77.                     return true;
  78.                 }
  79.                 else
  80.                 {
  81.                     return false;
  82.                 }
  83.             }
  84.  
  85. //------------------ function to disable radio button choice for repeat event -------------------------------------------
  86.             function disableRepeatRadio()
  87.             {
  88.                 //document.forms.comform.allDays[1].checked = true;
  89.                 //Select the "For the following days" option
  90.                 document.forms.comform.allDays.value = 0;
  91.             }
  92.  
  93. //------------------- function to disable check boxes for Repeat Event ------------------------------------------------
  94.             function disableRepeatCheckBox()
  95.             {
  96.                 document.forms.comform.Sun.checked = false;
  97.                 document.forms.comform.Mon.checked = false;
  98.                 document.forms.comform.Tue.checked = false;
  99.                 document.forms.comform.Wed.checked = false;
  100.                 document.forms.comform.Thu.checked = false;
  101.                 document.forms.comform.Fri.checked = false;
  102.                 document.forms.comform.Sat.checked = false;
  103.             }
  104.  
  105. //--------------------function to enable all check boxes for Repeat Event--------------------------------------------------
  106.             function chkAllDays()
  107.             {
  108.                 var condition = !document.forms.comform.Sun.checked;
  109.                 document.forms.comform.Sun.checked = condition;
  110.                 document.forms.comform.Mon.checked = condition;
  111.                 document.forms.comform.Tue.checked = condition;
  112.                 document.forms.comform.Wed.checked = condition;
  113.                 document.forms.comform.Thu.checked = condition;
  114.                 document.forms.comform.Fri.checked = condition;
  115.                 document.forms.comform.Sat.checked = condition;
  116.             }
  117.  
  118. //--------------- Function to select the proper radio option for the repeatation ------------------
  119.             function unselectBtn()
  120.             {
  121.                 if(document.forms.comform.radRepeat[0].checked)
  122.                 {
  123.                     document.forms.comform.radAlwaysUntil[0].checked = false;
  124.                     document.forms.comform.radAlwaysUntil[1].checked = false;
  125.                     document.forms.comform.txtRepeatCount.value="";
  126.                 }
  127.             }
  128.  
  129. // ----------------- function to disable radio box selection for reminders when the chkbox is clicked ---------------------
  130.             
  131.             function disableRadio(num)
  132.             {
  133.               var checkBoxNum;
  134.               eval("checkBoxNum = document.forms.comform.chkRemind" + num + ";");
  135.               checkBoxNum.checked = true;
  136.               document.forms.comform.radRemind.checked = false;
  137.               if(document.forms.comform.chkRemind1.checked == false && document.forms.comform.chkRemind2.checked  == false)//if no chk box is selected then select the radio box
  138.               {
  139.                 document.forms.comform.radRemind.checked = true;
  140.               }
  141.             }
  142.  
  143. // ----------------- function to disable check box  selection for reminders when the radiobox is clicked ---------------------
  144.             
  145.             function disableCheckBox()
  146.             {
  147.                 document.forms.comform.chkRemind1.checked = false;
  148.                 document.forms.comform.chkRemind2.checked = false;
  149.             }
  150.  
  151. //--------------- Function to set flag  for Trigger 1------------------------------------------------------------
  152.             function chkTrig()
  153.             {
  154.                 trgflag1 = 1;
  155.             }
  156.  
  157. //--------------- Function to set flag  for Trigger 2------------------------------------------------------------
  158.             function chkMltTrig()
  159.             {
  160.                 trgflag = 1;
  161.             }
  162.  
  163. //--------------- Function to check whether addresee present or not in the address book --------------------------------
  164.             function chkAddresee()
  165.             {
  166.                 var indexAddress = document.forms.comform.remindAttendee.selectedIndex;
  167.                 if(indexAddress == -1)
  168.                 {
  169.                     alert("Please select address from the Address Book!");
  170.                 }
  171.                 else if(document.forms.comform.remindAttendee.length == 1 && document.forms.comform.remindAttendee.options[indexAddress].text == "No Addressee")
  172.                 {
  173.                     alert("No addresses present in the Address Book!");
  174.                     document.forms.comform.UI_AlarmAttendee.focus();
  175.                 }
  176.                 else
  177.                     setReminderEmailValues();
  178.             }
  179.  
  180. //-------------- Function to get the email address from the address book to the email field ----------------------------
  181.  
  182.             function setReminderEmailValues()
  183.             {
  184.                 var tmp_Uname,tmp_Uid,tmp_string,i,j,k;
  185.                 var sel_index = 0;
  186.                 var reminderEmail;
  187.                 var sel_invetees = new Array();
  188.                 k = 0;
  189.  
  190. //-------------- New code for multiple selection ----------------------------------
  191.                 for(i=0; i < document.forms.comform.remindAttendee.length; i++)
  192.                 {
  193.                     if(document.forms.comform.remindAttendee.options[i].selected == true)
  194.                     {
  195.                         sel_invetees[k] = i;
  196.                         k++;
  197.                     }
  198.                 }
  199.                 if(sel_invetees.length > 1)
  200.                 {
  201.                     var tmp_name,tmp_str,tmp_emlid,tmp_atndstr;
  202.                     for(i=0; i < sel_invetees.length; i++)
  203.                     {
  204.                         tmp_atndstr = document.forms.comform.UI_AlarmAttendee.value ;
  205.                         tmp_str = document.forms.comform.remindAttendee.options[sel_invetees[i]].text;
  206.                         tmp_emlid = tmp_str;
  207.  
  208.                         if(tmp_atndstr.length == 0 || tmp_atndstr == "")
  209.                         {
  210.                             tmp_atndstr = tmp_emlid ;
  211.                         }
  212.                         else
  213.                         {
  214.                             tmp_atndstr = tmp_atndstr + "\n" + tmp_emlid ;
  215.                         }
  216.                         
  217.                         document.forms.comform.UI_AlarmAttendee.value = tmp_atndstr;
  218.                         tmp_str = "";
  219.                         tmp_emlid = "";
  220.                     }
  221.                 }
  222. //-------------- End new code -----------------------------------------------------
  223.                 else
  224.                 {
  225.                     sel_index = document.forms.comform.remindAttendee.selectedIndex;
  226.                     tmp_string = document.forms.comform.remindAttendee.options[sel_index].text;
  227.                 
  228.                     if(tmp_string.length == 0 || tmp_string == "")
  229.                     {
  230.                         document.forms.comform.UI_AlarmAttendee.value = "";
  231.                     }
  232.                     
  233.                     tmp_Uid = tmp_string;
  234.  
  235.                     reminderEmail = document.forms.comform.UI_AlarmAttendee.value;
  236.                     if(reminderEmail == "")                
  237.                         document.forms.comform.UI_AlarmAttendee.value = tmp_Uid;
  238.                     else
  239.                     {
  240.                         reminderEmail = reminderEmail + "\n" + tmp_Uid ;
  241.                         document.forms.comform.UI_AlarmAttendee.value = reminderEmail;
  242.                     }
  243.  
  244.                 }
  245.             }
  246.  
  247. //--------------- Function to check whether addresee present or not in the address book --------------------------------
  248.             function chkInviteeAddresee()
  249.             {
  250.                 var indexAddress = document.forms.comform.emailAttendee.selectedIndex;
  251.                 if(indexAddress == -1)
  252.                 {
  253.                     alert("Please select address from the Address Book!");
  254.                 }
  255.                 else if(document.forms.comform.emailAttendee.length == 1 && document.forms.comform.emailAttendee.options[indexAddress].text == "No Addressee")
  256.                 {
  257.                     alert("No addresses present in the Address Book!");
  258.                     document.forms.comform.UI_Attendee.focus();
  259.                 }
  260.                 else
  261.                     setEmailValues();
  262.             }
  263.  
  264. //-------------------------- address book support for Attendees --------------------------
  265.  
  266.             function setEmailValues()
  267.             {
  268.                 var tmp_Uname,tmp_Uid,tmp_string,i,j,k;
  269.                 var sel_index = 0;
  270.                 var reminderEmail;
  271.                 var sel_inveteeseml = new Array();
  272.                 k = 0;
  273. //--------------- New code for multiple selection --------------------------
  274.                 for(i=0; i < document.forms.comform.emailAttendee.length; i++)
  275.                 {
  276.                     if(document.forms.comform.emailAttendee.options[i].selected == true)
  277.                     {
  278.                         sel_inveteeseml[k] = i;
  279.                         k++;
  280.                     }
  281.                 }
  282.                 if(sel_inveteeseml.length > 1)
  283.                 {
  284.                     var tmp_atname,tmp_atemlid,tmpat_str,tmp_atatndstr;
  285.                     for(i=0; i < sel_inveteeseml.length; i++)
  286.                     {
  287.                         tmp_atatndstr = document.forms.comform.UI_Attendee.value ;
  288.                         tmp_atstr = document.forms.comform.emailAttendee.options[sel_inveteeseml[i]].text;
  289.                         tmp_atemlid = tmp_atstr;
  290.                         if(tmp_atatndstr.length == 0 || tmp_atatndstr == "")
  291.                         {
  292.                             tmp_atatndstr = tmp_atemlid ;
  293.                         }
  294.                         else
  295.                         {
  296.                             tmp_atatndstr = tmp_atatndstr + "\n" + tmp_atemlid ;
  297.                         }
  298.  
  299.                         document.forms.comform.UI_Attendee.value = tmp_atatndstr;
  300.                         tmp_atstr = "";
  301.                         tmp_atemlid = "";
  302.                     }
  303.                 }
  304. //--------------- End new code ---------------------------------------------
  305.                 else
  306.                 {
  307.                     sel_index = document.forms.comform.emailAttendee.selectedIndex;
  308.                     tmp_string = document.forms.comform.emailAttendee.options[sel_index].text;
  309.             
  310.                     if(tmp_string.length == 0 || tmp_string == "")
  311.                     {
  312.                         document.forms.comform.UI_Attendee.value = "";
  313.                     }
  314.             
  315.                     tmp_Uid = tmp_string;
  316.                     
  317.                     reminderEmail = document.forms.comform.UI_Attendee.value;
  318.                     if(reminderEmail == "")                
  319.                         document.forms.comform.UI_Attendee.value = tmp_Uid;
  320.                     else
  321.                     {
  322.                         reminderEmail = reminderEmail + "\n" + tmp_Uid ;
  323.                         document.forms.comform.UI_Attendee.value = reminderEmail;
  324.                     }
  325.                 }
  326.             }
  327.  
  328. //--------------- Function to compare the start date and end date of the event --------------------
  329.             function dateComp()
  330.             {
  331.                 var sDay,sMonth,sYear,sHr,sMin,eDay,eMonth,eYear,eHr,eMin;
  332.                 sDay = document.forms.comform.selDay.selectedIndex;
  333.                 sMonth = document.forms.comform.selMonth.selectedIndex;
  334.                 sYear = document.forms.comform.selYear.selectedIndex;
  335.                 sHr = document.forms.comform.selHr.selectedIndex;
  336.                 sMin = document.forms.comform.selMin.selectedIndex;
  337.                 eDay = document.forms.comform.selEDay.selectedIndex;
  338.                 eMonth = document.forms.comform.selEMonth.selectedIndex;
  339.                 eYear = document.forms.comform.selEYear.selectedIndex;
  340.                 eHr = document.forms.comform.selEHr.selectedIndex;
  341.                 eMin = document.forms.comform.selEMin.selectedIndex;
  342.  
  343.                 //check for the type of the clock i.e 12/24
  344.  
  345.                 if(clkHours == "12")
  346.                 {
  347.                     if(document.forms.comform.clkAmPm.options[0].selected == true)
  348.                     {
  349.                         if(document.forms.comform.selHr.options[11].selected == true)
  350.                         {
  351.                             var tmp_hour = "00";
  352.                             tmp_hour = parseFloat(tmp_hour);
  353.                         }
  354.                         else
  355.                         {
  356.                             var tmp_hour = document.forms.comform.selHr.options[document.forms.comform.selHr.selectedIndex].value;
  357.                             tmp_hour = parseFloat(tmp_hour);
  358.                         }
  359.                     }
  360.                     else if(document.forms.comform.clkAmPm.options[1].selected == true)
  361.                     {
  362.                         if(document.forms.comform.selHr.options[11].selected == true)
  363.                         {
  364.                             var tmp_hour = document.forms.comform.selHr.options[document.forms.comform.selHr.selectedIndex].value;
  365.                             tmp_hour = parseFloat(tmp_hour);
  366.                         }
  367.                         else
  368.                         {
  369.                             var tmp_hour = document.forms.comform.selHr.options[document.forms.comform.selHr.selectedIndex].value;
  370.                             tmp_hour = parseFloat(tmp_hour);
  371.                             tmp_hour = tmp_hour + 12;
  372.                             if(tmp_hour > 23)
  373.                             {
  374.                                 tmp_hour = 0;
  375.                             }
  376.                         }
  377.                     }
  378.  
  379.                     if(document.forms.comform.clkEAmPm.options[0].selected == true)
  380.                     {
  381.                         if(document.forms.comform.selEHr.options[11].selected == true)
  382.                         {
  383.                             var tmp_ehour = "00";
  384.                             tmp_ehour = parseFloat(tmp_ehour);
  385.                         }
  386.                         else
  387.                         {
  388.                             var tmp_ehour = document.forms.comform.selEHr.options[document.forms.comform.selEHr.selectedIndex].value;
  389.                             tmp_ehour = parseFloat(tmp_ehour);
  390.                         }
  391.                     }
  392.                     else if(document.forms.comform.clkEAmPm.options[1].selected == true)
  393.                     {
  394.                         if(document.forms.comform.selEHr.options[11].selected == true)
  395.                         {
  396.                             var tmp_ehour = document.forms.comform.selEHr.options[document.forms.comform.selEHr.selectedIndex].value;
  397.                             tmp_ehour = parseFloat(tmp_ehour);
  398.                         }
  399.                         else
  400.                         {
  401.                             var tmp_ehour = document.forms.comform.selEHr.options[document.forms.comform.selEHr.selectedIndex].value;
  402.                             tmp_ehour = parseFloat(tmp_ehour);
  403.                             tmp_ehour = tmp_ehour + 12;
  404.                             if(tmp_ehour > 23)
  405.                             {
  406.                                 tmp_ehour = 0;
  407.                             }
  408.                         }
  409.                     }
  410.  
  411.                     if(eYear < sYear)
  412.                     {
  413.                         return true;
  414.                     }
  415.                     else if(eYear == sYear && eMonth < sMonth)
  416.                     {
  417.                         return true;
  418.                     }
  419.                     else if(eYear == sYear && eMonth == sMonth && eDay < sDay)
  420.                     {
  421.                         return true;
  422.                     }
  423.                     else if(eYear == sYear && eMonth == sMonth && eDay == sDay && tmp_ehour < tmp_hour)
  424.                     {
  425.                         return true;
  426.                     }
  427.                     else if(eYear == sYear && eMonth == sMonth && eDay == sDay && tmp_ehour == tmp_hour && eMin < sMin)
  428.                     {
  429.                         return true;
  430.                     }
  431.                     else
  432.                     {
  433.                         return false;
  434.                     }
  435.                 }
  436.                 else   //for 24 hr clock
  437.                 {                    
  438.                     if(eYear < sYear)
  439.                     {
  440.                         return true;
  441.                     }
  442.                     else if(eYear == sYear && eMonth < sMonth)
  443.                     {
  444.                         return true;
  445.                     }
  446.                     else if(eYear == sYear && eMonth == sMonth && eDay < sDay)
  447.                     {
  448.                         return true;
  449.                     }
  450.                     else if(eYear == sYear && eMonth == sMonth && eDay == sDay && eHr < sHr)
  451.                     {
  452.                         return true;
  453.                     }
  454.                     else if(eYear == sYear && eMonth == sMonth && eDay == sDay && eHr == sHr && eMin < sMin)
  455.                     {
  456.                         return true;
  457.                     }
  458.                     else
  459.                     {
  460.                         return false;
  461.                     }
  462.                 } //for 24 hr clock
  463.             }
  464.